import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, OneToMany } from 'typeorm';
import { User } from '../../users/entities/user.entity';
import { FollowUp } from './follow-up.entity';

@Entity()
export class Agent {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @Column()
  contact: string;

  @Column()
  phone: string;

  @Column()
  address: string;

  @Column()
  createTime: string;

  @Column()
  source: string;

  @Column({
    type: 'enum',
    enum: ['active', 'inactive'],
    default: 'active'
  })
  status: 'active' | 'inactive';

  @Column({
    type: 'enum',
    enum: [0, 1, 2, 3],
    default: 0
  })
  type: 0 | 1 | 2 | 3;

  @ManyToOne(() => User, user => user.id)
  assignedTo?: User | null;

  @ManyToOne(() => User, user => user.id)
  lastAssignedTo?: User | null;

  @OneToMany(() => FollowUp, followUp => followUp.agent)
  followUps: FollowUp[];
} 